<template>
    <div>
        <header-bar :title="$route.meta.title">
            <template #right>
                <van-icon name="search" size="18"/>
            </template>
        </header-bar>
        <!--    <van-search v-model="search.text" placeholder="请输入搜索关键词" @search="searchSubmit" />-->
        <van-pull-refresh v-model="refreshing" @refresh="_onRefresh">
            <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="_onLoad">
                <van-cell v-for="item in list" :key="item.id" :title="item.createTime" :value="item.type"
                          :label="item.content"/>
            </van-list>
        </van-pull-refresh>
    </div>
</template>

<script>
    import pageMixin from "@/utils/mixins/page";
    import * as userApi from '@/api/user';

    import {List, Cell, PullRefresh, Search} from "vant";

    export default {
        mixins: [pageMixin],
        // 数据列表
        data() {
            return {
                list: [],
                search: {text: ""}
            };
        },
        components: {
            [List.name]: List,
            [Cell.name]: Cell,
            [PullRefresh.name]: PullRefresh,
            [Search.name]: Search
        },
        mounted() {
            console.log(this.$route.query);
        },
        methods: {
            // 搜索
            searchSubmit() {
                // 调用混合搜索
                this._searchData();
            },
            // 数据请求(没错就是这么少的代码)
            async _getList() {
                // 根据实际情况修改自己修改key
                let requestParams = {
                    pageNum: this.page, // 传入页码
                    pageSize: 1000, // 传入每页条数
                    search: this.search // 传入搜索的对象
                }
                userApi.getClockList(requestParams).then(res =>{
                    console.log(res)
                    this.total = res.total;
                    res.rows.map(item => {
                        this.list.push(item);
                    });
                }).catch(err =>{
                    console.log(err)
                }).finally(() => {
                    //console.log('无论正确错误，都会执行')
                })

            }
        }
    };
</script>
<style scoped lang="scss">
</style>
